package com.bigfish.controller;

import com.bigfish.feign.CouponFeignService;
import com.bigfish.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RefreshScope
@RequestMapping("/member/member")
public class MemberController {

    @Autowired
    private CouponFeignService couponFeignService;

    //    读取application.properties文件中的配置信息
    @Value("${member.user.name}")
    private String name;
    @Value("${member.user.age}")
    private Integer age;

    @RequestMapping("/coupons")
    public R coupons() {
        R membersCoupons = couponFeignService.membersCoupons();
        return R.ok().put("member", Map.of("username", "张三", "sex", "男")).put("coupons", membersCoupons);
    }

    @RequestMapping("/test")
    public R test() {
        return R.ok().put("name", name).put("age", age);
    }
}
